package com.artollkitplus.benchmark;

import android.graphics.Color;
import android.text.StaticLayout;
import android.text.TextPaint;
import android.text.Layout.Alignment;

public class CurrentConfig implements Config{
	public static boolean SDCARD_AVAILABLE = false;
	public static boolean SHOW_FPS = true;
	public static boolean SHOW_CONFIGURATION = true;
	public static boolean MENU_PAUSE_SCREEN_ON = false;
	public static boolean USE_MENU_PAUSE_SCREEN = false;
	public static boolean ONLY_CAMERA_PREVIEW = false;
	public static int DEFAULT_IMAGE_WIDTH = 320;//starting image size parameters in onPreviewFreme() method
	public static int DEFAULT_IMAGE_HEIGT = 240;
	//optimal image size 
	public static int OPTIMAL_IMAGE_WIDTH = 320;
	public static int OPTIMAL_IMAGE_HEIGT = 240;
	//800 I9000//640 nexus
	//480
	
	//version
	public static String APP_VERSION = "Version: 1.14\n";
	// current menu settings
 	public static int CURRENT_MENU_GROUP_SETTINGS = BIT_GROUP_ARTOOLKIT_PLUS|BIT_GROUP_ARTOOLKIT_PLUS_SINGLE;
 	//current ar settings
 	public static long CURRENT_AR_SETTINGS = BIT_MODE_AR_ARTOOLKIT_PLUS |BIT_IMAGE_SIZE_120x90|BIT_MODE_MARKER_TYPE_BCH|BIT_MODE_POSE_ESTIMATOR_ORIGINAL_CONT|BIT_MODE_TRACKER_BASE_TYPE_SINGLE|BIT_MODE_HULL_OFF;
 	//current image mode settings
 	public static long CURRENT_IMAGE_SETTINGS = BIT_MODE_IMAGE_RGB;
 	//configuration text info 
 	public static String CONFIG_INFO_TEXT = "";
 	//current AR Library setting
 	public static boolean USE_ARTOOLKITPLUS = useARToolKitPlus();
 	
 	//for display wrapped config text
 	private static TextPaint textPaint = new TextPaint();
 	public static StaticLayout TEXT_LAYOUT = new StaticLayout(CurrentConfig.CONFIG_INFO_TEXT, textPaint, 100, Alignment.ALIGN_NORMAL, (float)1.0, (float)0.0, true);
 	
 	public static void updateConfigurationString(){
 		StringBuffer config = new StringBuffer();
 		config.append(APP_VERSION);
 		if((CURRENT_AR_SETTINGS&BIT_MODE_AR_ARTOOLKIT)>0){
 			config.append("ARToolKit\n");
 		}else if((CURRENT_AR_SETTINGS&BIT_MODE_AR_ARTOOLKIT_PLUS)>0){
 			config.append("ARToolKitPlus\n");
 		}
 		//////////////////////////////////////////////////
 		if((CURRENT_IMAGE_SETTINGS&BIT_MODE_IMAGE_RGB)>0){
 			config.append("Image mode: RGB\n");
 		}else if((CURRENT_IMAGE_SETTINGS&BIT_MODE_IMAGE_GRAY)>0){
 			config.append("Image mode: luminance\n");
 		}
 		//////////////////////////////////////////////////
 		String suffix = "Requested Preview image size: ";
 		if((CURRENT_AR_SETTINGS&BIT_IMAGE_SIZE_320x240)>0){
 			config.append(suffix+"320x240\n");
 		}else if((CURRENT_AR_SETTINGS&BIT_IMAGE_SIZE_300x225)>0){
 			config.append(suffix+"300x225\n");
 		}else if((CURRENT_AR_SETTINGS&BIT_IMAGE_SIZE_280x210)>0){
 			config.append(suffix+"280x210\n");
 		}else if((CURRENT_AR_SETTINGS&BIT_IMAGE_SIZE_260x195)>0){
 			config.append(suffix+"260x195\n");
 		}else if((CURRENT_AR_SETTINGS&BIT_IMAGE_SIZE_240x180)>0){
 			config.append(suffix+"240x180\n");
 		}else if((CURRENT_AR_SETTINGS&BIT_IMAGE_SIZE_220x165)>0){
 			config.append(suffix+"220x165\n");
 		}else if((CURRENT_AR_SETTINGS&BIT_IMAGE_SIZE_200x150)>0){
 			config.append(suffix+"200x150\n");
 		}else if((CURRENT_AR_SETTINGS&BIT_IMAGE_SIZE_180x135)>0){
 			config.append(suffix+"180x135\n");
 		}else if((CURRENT_AR_SETTINGS&BIT_IMAGE_SIZE_160x120)>0){
 			config.append(suffix+"160x120\n");
 		}else if((CURRENT_AR_SETTINGS&BIT_IMAGE_SIZE_140x105)>0){
 			config.append(suffix+"140x105\n");
 		}else if((CURRENT_AR_SETTINGS&BIT_IMAGE_SIZE_120x90)>0){
 			config.append(suffix+"120x90\n");
 		}else if((CURRENT_AR_SETTINGS&BIT_IMAGE_SIZE_480x320)>0){//new
 			config.append(suffix+"480x320\n");
 		}else if((CURRENT_AR_SETTINGS&BIT_IMAGE_SIZE_800x480)>0){//new
 			config.append(suffix+"800x480\n");
 		}else if((CURRENT_AR_SETTINGS&BIT_IMAGE_SIZE_OPTIMAL)>0){//new
 			config.append(suffix+"OPTIMAL\n");
 		}
 		/////////////////////////
 		config.append("Image width "+DEFAULT_IMAGE_WIDTH+" height "+DEFAULT_IMAGE_HEIGT+"\n");
 		/////////////////////////
 		if((CURRENT_AR_SETTINGS&BIT_MODE_MARKER_TYPE_TEMPLATE)>0){
 			config.append("Marker: template\n");
 		}else if((CURRENT_AR_SETTINGS&BIT_MODE_MARKER_TYPE_SIMPLE)>0){
 			config.append("Marker: simple\n");
 		}else if((CURRENT_AR_SETTINGS&BIT_MODE_MARKER_TYPE_BCH)>0){
 			config.append("Marker: BCH\n");
 		}
 		//////////////////////
 		if((CURRENT_AR_SETTINGS&BIT_MODE_POSE_ESTIMATOR_ORIGINAL)>0){
 			config.append("Pose estimator: original\n");
 		}else if((CURRENT_AR_SETTINGS&BIT_MODE_POSE_ESTIMATOR_ORIGINAL_CONT)>0){
 			config.append("Pose estimator: original cont\n");
 		}else if((CURRENT_AR_SETTINGS&BIT_MODE_POSE_ESTIMATOR_RPP)>0){
 			config.append("Pose estimator: RPP\n");
 		}
 		///////////////////
 		if((CURRENT_AR_SETTINGS&BIT_MODE_TRACKER_BASE_TYPE_SINGLE)>0){
 			config.append("Tracker: single\n");
 		}else if((CURRENT_AR_SETTINGS&BIT_MODE_TRACKER_BASE_TYPE_MULTI)>0){
 			config.append("Tracker: multi\n");
 		}else if((CURRENT_AR_SETTINGS&BIT_MODE_HULL_OFF)>0){
 			config.append("Hull: off\n");
 		}else if((CURRENT_AR_SETTINGS&BIT_MODE_HULL_FOUR)>0){
 			config.append("Hull: four\n");
 		}else if((CURRENT_AR_SETTINGS&BIT_MODE_HULL_FULL)>0){
 			config.append("Hull: full\n");
 		}	
 		/////
 		USE_ARTOOLKITPLUS = useARToolKitPlus();
 		/////
 		CONFIG_INFO_TEXT = config.toString();
 		textPaint.setColor(Color.GREEN);
 		TEXT_LAYOUT = new StaticLayout(CurrentConfig.CONFIG_INFO_TEXT, textPaint, 280, Alignment.ALIGN_NORMAL, (float)1.0, (float)0.0, true);
 	}
 	
 	public static boolean useARToolKitPlus(){
 		if((CURRENT_AR_SETTINGS&BIT_MODE_AR_ARTOOLKIT_PLUS)>0){
 			return true;
		}else{
			return false;
		}
 	}
}
